package com.djl.zenithbite.util;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.DigestUtils;

import java.util.UUID;

public class EncryptUtil {
    public static String generateSalt() {
        return UUID.randomUUID().toString().replaceAll("-", "").substring(0,5);
    }

    public static String encryptPassword(String password) {
        if (StringUtils.isBlank(password)) {
            return "";
        }

        return DigestUtils.md5DigestAsHex(password.getBytes());
    }
}
